﻿namespace com.stifel.BranchMgmt.WebParts.BranchView
{
    using System.Collections.Generic;
    using System.Text;

    using com.stifel.BranchMgmtDao;
    using com.stifel.Extensions.SharePointExtensions;

    using Microsoft.SharePoint;

    public partial class BranchViewUserControl
    {
        #region Fields

        List<uiPhone_Data> _uiPhone_Data_List;

        #endregion Fields

        #region Properties

        List<uiPhone_Data> uiPhone_Data_List
        {
            get
            {
                if ( _uiPhone_Data_List == null )
                    _uiPhone_Data_List = new List<uiPhone_Data>( );
                return _uiPhone_Data_List;
            }
            set
            {
                _uiPhone_Data_List = value;
            }
        }

        #endregion Properties

        #region Methods

        void loadPhone( int branchId )
        {
            StifelTelephoneSystemDao dao = new StifelTelephoneSystemDao( SPContext.Current.Web.Url );
            List<StifelTelephoneSystem> l = dao.GetByBranchLocation( branchId );
            foreach ( StifelTelephoneSystem o in l )
                uiPhone_Data_List.Add( new uiPhone_Data( o ) );
            uiPhone_Repeater.DataSource = uiPhone_Data_List;
            uiPhone_Repeater.DataBind( );
        }

        #endregion Methods

        #region Nested Types

        protected class uiPhone_Data
        {
            #region Constructors

            public uiPhone_Data( StifelTelephoneSystem value )
            {
                Item = value.Title;
                CircuitID = value.TelephoneCircuitIds;
                Note = value.TelephoneEquipment;
                Contract = value.HasMaintenanceContract && value.ContractExpiration.HasValue ? value.ContractExpiration.Value.ToShortDateString( ) : string.Empty;
            }

            #endregion Constructors

            #region Properties

            public string CircuitID
            {
                get;
                set;
            }

            public string Contract
            {
                get;
                set;
            }

            public string Item
            {
                get;
                set;
            }

            public string Note
            {
                get;
                set;
            }

            public string value
            {
                get;
                set;
            }

            #endregion Properties
        }

        #endregion Nested Types
    }
}